package cn.wjssl.domain.activity.service.quota.rule.factory;

import cn.wjssl.domain.activity.service.quota.rule.IActionChain;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @Author：lxd
 * @Description
 * @Date：2025/2/19
 */

@Slf4j
@Component
public class DefaultActivityChainFactory {

    @Resource
    private Map<String, IActionChain> actionChainMap;

    // 获取责任链
    public IActionChain openActionChain() {
        IActionChain actionChain = actionChainMap.get(ActionModel.activity_base_action.code);   // 先是基础信息校验
        actionChain.appendNext(actionChainMap.get(ActionModel.activity_sku_stock_action.getCode()));    // 再是库存校验
        return actionChain;
    }

    @Getter
    @AllArgsConstructor
    public enum ActionModel {

        activity_base_action("activity_base_action", "活动的库存、时间校验"),
        activity_sku_stock_action("activity_sku_stock_action", "活动sku库存"),
        ;

        private final String code;
        private final String info;

    }
}
